<template>
<h1>视频上传{{courseId}}</h1>
  <el-button type="primary" @click="back">返回章节</el-button>
  <div>
    <el-upload
        class="upload-demo"

        action="http://localhost:8080/studyadmin/video/uploadVideo"
        multiple
        name="video"
        :show-file-list="false"
        :on-success="handleAvatarSuccess"
        :before-upload="beforeAvatarUpload"
    >
      <el-button style="margin-left: 200px" type="primary">Click to upload</el-button>
<!--      <div class="el-upload__text">-->
<!--        Drop file here or <em>click to upload</em>-->
<!--      </div>-->
      <template #tip>
        <div class="el-upload__tip">
          视频格式为MP4 /大小不超过1GB
        </div>
      </template>
    </el-upload>
  </div>


</template>

<script>

import {ElMessage} from "element-plus";

export default {
  props:{
    value:Number,
    chaId:Number,
  },
  name: "UploadVideo",
  data(){
    return{
      courseId:this.value,
      chaId:this.chaId,

    }
  },


mounted() {
  // console.log("======prop========",props.value)
},
  methods: {
    back() {
      this.$parent.active = 0
    },

    beforeAvatarUpload() {

    },

    handleAvatarSuccess(res) {

      // console.log("==============", res.data)
      // console.log("======prop========", this.courseId)
      // console.log("======chaId========", this.chaId)

        let _this = this
        let url = "/studyadmin/video/updateVideo"
        _this.$axios.get(url,{params:{videoUrl:res.data,courseId:this.courseId,chaId:this.chaId}}).then(function(data){

          if (data.data.code === 0){

            ElMessage.success(data.data.msg)
          }else {
            ElMessage.error(data.data.msg)
          }
        }).catch(function(){

        })
      },


  }
}
</script>

<style scoped>

</style>